TwosComplementBuffer.pack   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 11
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 11
rs 10
c 0
b 0
f 0
cc 1
1
// Type definitions for twos-complement-buffer 1.0.0
2
// Project: https://github.com/rochars/twos-complement-buffer
3
// Definitions by: Rafael da Silva Rocha <https://github.com/rochars>
4
// Definitions: https://github.com/rochars/twos-complement-buffer
5
6
export = TwosComplementBuffer;
7
8
declare module TwosComplementBuffer {
9
10
  class TwosComplementBuffer {
11
    /**
12
     * @param {number} bits The number of bits used by the integer.
13
     */
14
    constructor(bits: number);
15
16
    /**
17
     * The number of bytes used by the number.
18
     * @type {number}
19
     */
20
    bits: number;
21
22
    /**
23
     * The number of bytes used by the number.
24
     * @type {number}
25
     */
26
    bytes: number;
27
28
    /**
29
     * Write one two's complement signed integer to a byte buffer.
30
     * @param {!Uint8Array|!Array<number>} buffer An array of bytes.
31
     * @param {number} num The number.
32
     * @param {number=} index The index being written in the byte buffer.
33
     * @return {number} The next index to write on the byte buffer.
34
     * @throws {TypeError} If num is NaN.
35
     * @throws {RangeError} On overflow.
36
     */
37
    pack(buffer: Uint8Array|number[], num: number, index?: number): number;
38
39
    /**
40
     * Read one two's complement signed integer from a byte buffer.
41
     * @param {!Uint8Array|!Array<number>} buffer An array of bytes.
42
     * @param {number=} index The index to read.
43
     * @return {number}
44
     * @throws {RangeError} On overflow.
45
     */
46
    unpack(buffer: Uint8Array|number[], index?: number): number;
47
  }
48
}
49